package com.can.Mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.can.domain.vo.RepliesVo;
import org.apache.ibatis.annotations.Mapper;
import com.can.domain.po.post;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<post> {
    @Select("""
        SELECT 
            id, 
            user_id AS userId, 
            content, 
            username, 
            DATE_FORMAT(created_at, '%Y年%c月%e日%H时%i分') AS createdAt 
        FROM posts 
        WHERE id = #{postId}
        ORDER BY created_at 
        """)
    post getPostByPostId(int postId);
    @Options(useGeneratedKeys = true, keyProperty = "id")  // 关键注解
    int insert(post post);   //自动生成的id回填到po类的id字段
}
